import com.sun.org.apache.xml.internal.utils.StringToIntTable;

import java.sql.SQLOutput;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024 —03 —10
 * Time: 20:09
 */
public class test {

    public static void main11(String[] args) {
        String str = "helllo world hello bit ";
        String [] result = str.split(" ");//按照空格去分开这个字符串
        for (String x: result ) {
            System.out.println(x);
        }

    }

    public static void main10(String[] args) {
        String str1 = "hello bit ";
        String str2 = str1.replaceAll("l","a");
        System.out.println(str2);
        System.out.println(str1.replaceAll("l","a"));
        System.out.println("=============");

        String str3 = str1.replaceFirst("l","A");
        System.out.println(str3);
    }

    public static void main9(String[] args) {
        String s = String.format("%d-%d-%d",2024,3,10);
        System.out.println(s);

    }


    public static void main8(String[] args) {
        char [] ceshi = new char[]{'a','b','c'};
        System.out.println("ceshi");
        String s = "xinei";
        char [] array1 = s.toCharArray();//把字符串转化成了数组
        System.out.println(array1);
        System.out.println("========");
        for (int i = 0; i < array1.length ; i++) {
            System.out.print(array1[i]);
        }
        System.out.println();
        System.out.println("=========");
        String array2 = new String(s);
        System.out.println(array2);

    }

    public static void main7(String[] args) {
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        String s4 = String.valueOf(new String("hyy"));
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);

        System.out.println("========字符串转换成数字========");

        int data1 = Integer.parseInt("123124");
        double data2 = Double.parseDouble("12.56");
        System.out.println(data1);
        System.out.println(data2);


    }



    public static void main6(String[] args) {
        String s = "a1b2b3b1b2c3d4e5f6g7h8";
                   // 0123456789
        System.out.println(s.charAt(1));
       // System.out.println(s.charAt(20));//index越界了
        System.out.println("===========");
        System.out.println(s.indexOf("1b"));//字符串
        System.out.println(s.indexOf('b'));//字符
        System.out.println(s.indexOf('b',5));//左闭右开
        System.out.println(s.indexOf("1b",5));//左闭右开
        System.out.println("====================");
        System.out.println(s.lastIndexOf("b1"));//从后往前找在读取字符时候依旧是按照从左往右的顺序读取
        /*
        * 就三种类型
        * charAt   给数字返回index位置上的字符
        * indexOf   可以传字符串 指定开始读取的位置  单字符    4种
        * lastIndexOf   同上4种
        *
        * */

    }


    public static void main5(String[] args) {
        String s1 = new String("Abcde");
        String s2 = new String("abcde");
        String s3 = new String("abc");
        String s4 = new String("abcd");

        System.out.println(s1.compareToIgnoreCase(s2));//0
        System.out.println(s1.compareToIgnoreCase(s3));//2
    }



    public static void main4(String[] args) {
        String s1 = new String("abcde");
        String s2 = new String("abcdf");
        String s3 = new String("abc");
        String s4 = new String("abcde");

        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareTo(s3));
        System.out.println(s1.compareTo(s4));

    }



    public static void main3(String[] args) {
        String s1 = new String("第一次");
        String s2 = new String("第二次");
        String s3 = new String("第一次");

        System.out.println(s1 == s2);
        System.out.println(s1 == s3);//比较地址
        System.out.println(s1.equals(s3));//比较内容

    }


    public static void main2(String[] args) {
        String s1 = new String("第一次");
        String s2 = new String("第二次");
        String s3 = s1;//s1和s2指向的是同一个对象
        System.out.println(s1.length());//字符串长度为3
        System.out.println(s1.isEmpty());//判断该字符串长度为0返回：true  不为0返回：false
    }






    public static void main1(String[] args) {
        String s1 = "hello bit";
        System.out.println(s1);

        System.out.println("==========");

        String s2 = new String("hello bit");
        System.out.println(s2);

        System.out.println("============");
        char array1 [] = new char[] {'a'} ;
        String array2 [ ] = {"数组的第二种表现形式","WULIAO"};


        String  a1 = new String(array1);
        String  a2= new String(Arrays.toString(array2));
       // String  A2= new String(array2);//如果数组是字符串类型的话，要以Arrays.toString来打印
        System.out.println(a1);
        System.out.println(a2);
    }
}
